//Pad签署使用的js
    function inputDataHandle(msg){
        $("#contract").val(msg.content);
        $("#seq_id").val(msg.seq_id);
    }

    /**
     * 提交签署
     */
    function submitInfo (){
        $.ajax({
            type: "POST",
            data:$('#createContract').serialize(),
            url: "http://127.0.0.1:20175",
            dataType:"json",
            timeout: 60000,
            async:false,
            success:function(msg){
                console.log(msg);
                if(null != msg) {
                    if(msg.result=='OK') {
                        //$("#frm").submit();
                        return;
                    } else {
                        layer.alert("指令发送失败!");
                        return;
                    }
                } else {
                    layer.alert("指令发送失败!");
                    return;
                }
            }
        });
    }


    var dingshi2;
    var type="-1";
    var f=1;
    if(type!=1) {
        $("#info").hide();
    }
    var dingshi1 = setInterval(function() {
        f=1;
        console.log(123);
        console.log($("#other"));
        $.ajax({
            type: "POST",
            url: "http://127.0.0.1:20175",
            data:$("#other").serialize(),
            dataType:"json",
            async:false,
            success:function(msg){
                console.log(msg);
                if(null != msg){
                    if(msg.result=="OK") {
                        if (type == "-1") {
                            if (null != msg.sign_pic) {
                                $("#qianming").attr("src", "data:image/png;base64,"+msg.sign_pic);
                                window.clearTimeout(dingshi1);
                            }
                        }
                    }
                }
            }
        });
    },2000);

    function sub(flag) {
        window.clearTimeout(dingshi2);
        window.clearTimeout(dingshi1);
        if(flag=='2'){
            $("#qianming").attr("src","");
            $.ajax({
                type: "POST",
                data:$('#redo').serialize(),
                url: "http://127.0.0.1:20175",
                dataType:"json",
                async:false,
                success:function(msg){
                    if(null != msg){
                        if(msg.result != 'OK'){
                            layer.alert("指令发送失败!");
                            return;
                        }
                    }else{
                        layer.alert("指令发送失败!");
                        return;
                    }
                }
            });
            f=2;
            dingshi2 = setInterval(function(){
                $.ajax({
                    type: "POST",
                    url: "http://127.0.0.1:20175",
                    data:$('#other').serialize(),
                    dataType:"json",
                    async:false,
                    success:function(msg){
                        if(null != msg){
                            if(msg.result=="OK") {
                                if (type == "-1") {
                                    if (null != msg.sign_pic) {
                                        $("#qianming").attr("src", "data:image/png;base64," + msg.sign_pic);
                                        window.clearTimeout(dingshi2);
                                    }
                                }else {
                                    var info = msg;
                                    $("#pic").attr("src", "data:image/png;base64," + info.pic);
                                    $("#cardpic").attr("src", "data:image/png;base64," + info.cardpic);
                                    window.clearTimeout(dingshi2);
                                }
                            }

                        }
                    },
                    complete:function(msg) {

                    }
                });
            },5000);
        }
        if(flag=='1'){
            $(".btn").attr("disabled","disabled");
            if(f==1){
                window.clearTimeout(dingshi1);
            }
            if(f==2){
                window.clearTimeout(dingshi2);
            }
            $.ajax({
                type: "POST",
                data:$('#backhome').serialize(),
                url: "http://127.0.0.1:20175",
                timeout: 60000,
                dataType:"json",
                success:function(msg){
                    if(null != msg) {
                        if(msg.result=='OK') {
                            notice();
                            $(".btn").removeAttr("disabled");
                            return;
                        } else {
                            layer.alert("通知pad失败!");
                            $(".btn").removeAttr("disabled");
                            return;
                        }
                    } else {
                        layer.alert("指令发送失败!");
                        return;
                    }
                }
            });
            return;
        }
        if(flag=='3'){
            $(".btn").attr("disabled","disabled");
            if(f==1){
                window.clearTimeout(dingshi1);
            }
            if(f==2){
                window.clearTimeout(dingshi2);
            }
            $.ajax({
                type: "POST",
                data:$('#cancel').serialize(),
                url: "http://127.0.0.1:20175",
                timeout: 60000,
                dataType:"json",
                success:function(msg){
                    if(null != msg){
                        if(msg.result=='OK'){
                            cancelnotice();
                            return;
                        } else {
                            layer.alert("通知pad失败!");
                            $(".btn").removeAttr("disabled");
                            return;
                        }
                    }else{
                        layer.alert("指令发送失败!");
                        return;
                    }
                }
            });
            return;
        }
    }
    function cancelnotice() {
        window.location.href="${ctx}/contract/apiTemplate/list";
    }
    function notice(){
        var signbase64=$("#qianming").attr("src");
        $("#signbase64").attr("value",signbase64);
        layer.alert("传送数据成功!");
    }
